Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected session flush when calling AuditReader.GetCurrentRevision #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akonit
Copy link

@akonit akonit commented Jul 26, 2019

This is an illustration for the issue: #20

Anna Khaperskaia added 2 commits July 26, 2019 18:05
@RogerKratz
Copy link
Collaborator

DefaultRevisionEntity is behind the scenes mapped as a normal nhib entity with Id mapped with identity generator. When using identity as id generator, this is the behavior AFAIK => when entity is inserted (which it is at the time GetCurrentRevision(true) is called), a flush of the session will be forced.

It might help if you use a custom revision entity where Id is using generator HiLo or something else but identity. Haven't tried this myself though.

If identity generator is used in revision entity mapping (as default), this is something that needs to be fixed in NH Core (=not immediately flushing session when entity with identity Id mapping is used).

@RogerKratz
Copy link
Collaborator

BTW, why is current behavior causing problems for you?

@akonit
Copy link
Author

akonit commented Jul 27, 2019

using generator HiLo or something else but identity

That might work, I'll try it out.

My problem is application logic based on assumption of no flushes before commit. For example, I want to create a new entity, get current revision and to perform some recalculations overall entities in the same transaction. So I need to know how to process new entity when recalculating - it might be or not be presented when quering all entities, that depends on whether GetCurrentRevision was called. Such an ambiguity is troubling me.
Flushing after each insert/delete would be difficult for the code I am dealing with, I'm not even sure that it won't break something else. And that is why I was hoping to avoid flushes on GetCurrentRevision calls.

@RogerKratz
Copy link
Collaborator

<< That might work, I'll try it out. >>

Sounds good.

...btw, I assume GetCurrentRevision(false) wont work for you for some reason?

@akonit
Copy link
Author

akonit commented Jul 27, 2019

Yes, GetCurrentRevision(false) unfortunately is not an option for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants